<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2025/6/1
  Time: 15:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>商品管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link type="text/css" rel="stylesheet" href="css/index.css">
    <link type="text/css" rel="stylesheet" href="css/base.css">
</head>
<body>

<div class="container">

  <jsp:include page="header.jsp"></jsp:include>

  <div class="main goods-list">
    <div class="goods-list-btn">
      <button><a href="/admin/goods_list?is_removed=2">全部商品</a></button><br><br>
      <button><a href="/admin/goods_list?is_removed=0">在售商品</a></button><br><br>
      <button><a href="/admin/goods_list?is_removed=1">下架商品</a></button><br><br>
    </div>


    <table>
      <thead>
      <tr>
        <th>ID</th>
        <th>名称</th>
        <th>介绍</th>
        <th>详情图1</th>
        <th>详情图2</th>
        <th>详情图3</th>
        <th>新旧程度</th>
        <th>商品分类ID</th>
        <th>用户ID</th>
        <th>库存</th>
        <th>价格</th>
        <th>是否支持砍价</th>
        <th>发布时间</th>
        <th>商品状态</th>
        <th>操作</th>
      </tr>

      </thead>
      <tbody>
<%--      改为productList--%>
      <c:forEach items="${goodsList}" var="g">
        <tr>
          <td>${g.id}</td>
          <td>${g.name}</td>
          <td style="white-space: normal">${g.detail}</td>
          <td><img src="${pageContext.request.contextPath}${g.image1}" width="100px" height="100px"></td>
          <td><img src="${pageContext.request.contextPath}${g.image2}" width="100px" height="100px"></td>
          <td><img src="${pageContext.request.contextPath}${g.image3}" width="100px" height="100px"></td>
          <td>${g.old_level}</td>
          <td>${g.category_id}</td>
          <td>${g.user_id}</td>
          <td>${g.inventory}</td>
          <td>${g.price}</td>
          <td>
            <c:choose>
              <c:when test="${g.is_bargain=='true'}">支持砍价</c:when>
              <c:otherwise>不支持砍价</c:otherwise>
            </c:choose>
          </td>
          <td>${g.create_time}</td>
          <td>
            <c:choose>
              <c:when test="${g.is_removed=='flase'}">在售</c:when>
              <c:otherwise>已下架</c:otherwise>
            </c:choose>
          </td>
          <td class="table-actions">
            <c:if test="${g.is_removed=='false'}">
              <button class="delete-btn" onclick="location.href='/admin/goods_off?id=${g.id}'">下架</button>
            </c:if>
          </td>
        </tr>
      </c:forEach>
      </tbody>
    </table>
  </div>
</div>

</body>
</html>
